package string;

import java.util.Scanner;

/**
 * 判断某个字符在字符串中出现的次数
 * 
 * @author yy
 *
 */

public class JudgeCount {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.print("请输入一个字符串：");
		String str = input.next();
		System.out.print("请输入要查找的字符：");
		String str1 = input.next();
		int count = 0;
		for (int i = 0; i < str.length(); i++) {
			String str2 = str.substring(i, i + 1);
			if (str2.equals(str1)) {
				count++;
			}
		}
		System.out.println("“" + str + "”中包含" + count + "个“" + str1 + "”。");
	}
}
